package com.solcoo.controller;

import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.solcoo.service.UseromrelaService;

@Controller
public class UseromrelaController {

	@Resource
	private UseromrelaService useromrelaService;
	
	/**
	 * 新增子账户，传入ownerid、telephone，返回子账户信息
	 */
	@RequestMapping(value="addUseromrela.do")
	public @ResponseBody Map<String, Object> addUseromrela(String ownerid, 
			String telephone, String eno) throws Exception {
		return useromrelaService.addUseromrela(ownerid, telephone, eno);
	}
	
	/**
	 * 删除子账户，传入子账户ID，逻辑删除
	 */
	@RequestMapping(value="deleteUseromrela.do")
	public @ResponseBody Map<String, Object> deleteUseromrela(Long id) throws Exception {
		return useromrelaService.deleteUseromrela(id);
	}

	/**
	 * 修改子账户
	 */
	@RequestMapping(value="updateUseromrela.do")
	public @ResponseBody Map<String, Object> updateUseromrela(Long id, String eno) throws Exception {
		return useromrelaService.updateUseromrela(id, eno);
	}
	
	/**
	 * 获取子账户
	 */
	@RequestMapping(value="getUseromrela.do")
	public @ResponseBody Map<String, Object> getUseromrela(String ownerid, String employeeid) throws Exception {
		return useromrelaService.getEmployee(ownerid, employeeid);
	}
	
	/**
	 * 获取子账户列表
	 */
    @RequestMapping(value="listUseromrela.do")
    public @ResponseBody Map<String, Object> listUseromrela(String ownerid) throws Exception {
    	return useromrelaService.listEmployee(ownerid);
    }

    /**
     * 获取单个子账户及订单
     */
	@RequestMapping(value="getEmployeeOrder.do")
	public @ResponseBody Map<String, Object> getEmployeeOrder(String ownerid, 
			String employeeid, String date) throws Exception {
		return useromrelaService.getEmployeeOrder(ownerid, employeeid, date);
	}
	
	/**
     * 获取子账户列表及订单总额
     */
    @RequestMapping(value="listEmployeeOrder.do")
    public @ResponseBody Map<String, Object> listEmployeeOrder(String ownerid, String date) throws Exception {
    	return useromrelaService.listEmployeeOrder(ownerid, date);
    }
}